package demo.practice.tree.segment;

//P307
public class NumArray {

    public static void main(String[] args) {
        NumArray numArray= new NumArray(new int[]{1,3,5});
        numArray.sumRange(0,2);
        numArray.update(1,2);
        int i = numArray.sumRange(0, 2);
        System.out.println(i);

    }

    SegmentTree tree;
    public NumArray(int[] nums) {
        tree= new SegmentTree(nums);
    }

    public void update(int index, int val) {
        tree.update(index,val);
    }

    public int sumRange(int left, int right) {
       return tree.query(left,right);
    }
}
